<?php
defined('DT_ADMIN') or exit('Access Denied');
include tpl('header');
show_menu($menus);
?>
<!-- @#$ 20180424 -->
<script type="text/javascript" src="<?php echo DT_STATIC;?>file/script/jquery-ui.min.js"></script>
<!--<script type="text/javascript" src="--><?php //echo DT_STATIC;?><!--file/script/jquery.ui.touch-punch.min.js"></script>-->
<link rel="stylesheet" href="<?php echo DT_STATIC;?>file/script/jquery-ui.min.css">
<!-- @#$ 20180424 -->
<form action="?" target="_blank" id="check_title">
<input type="hidden" name="moduleid" value="<?php echo $moduleid;?>"/>
<input type="hidden" name="file" value="<?php echo $file;?>"/>
<input type="hidden" name="kw" value="" id="kw"/>
</form>
<form method="post" action="?" id="dform" onsubmit="return check();">
<input type="hidden" name="moduleid" value="<?php echo $moduleid;?>"/>
<input type="hidden" name="file" value="<?php echo $file;?>"/>
<input type="hidden" name="action" value="<?php echo $action;?>"/>
<input type="hidden" name="itemid" value="<?php echo $itemid;?>"/>
<input type="hidden" name="forward" value="<?php echo $forward;?>"/>
<table cellspacing="0" class="tb">
<tr>
<td class="tl"><span class="f_red">*</span> 所属分类</td>
<td><?php echo $_admin == 1 ? category_select('post[catid]', '选择分类', $catid, $moduleid) : ajax_category_select('post[catid]', '选择分类', $catid, $moduleid);?>&nbsp;&nbsp;<input type="checkbox" name="post[islink]" value="1" id="islink" onclick="_islink();" <?php if($islink) echo 'checked';?>/> 外部链接 <span id="dcatid" class="f_red"></span></td>
</tr>
<tr>
<td class="tl"><span class="f_red">*</span> 文档标题</td>
<td><input name="post[title]" type="text" id="title" size="80" value="<?php echo $title;?>"/> <?php echo level_select('post[level]', '级别', $level, 'id="level"');?> <?php echo dstyle('post[style]', $style);?>&nbsp;&nbsp;<input type="button" value="标题检测" onclick="check_title();" class="btn"/><span id="dtitle" class="f_red"></span></td>
</tr>
<tr>
    <td class="tl"><span class="f_hid">*</span> 首页标题</td>
    <td>
        <input name="post[headline]" type="text" id="headline" maxlength="50" size="60" value="<?php echo $headline;?>"/><span id="dheadline" class="f_red"></span>
        <span class="tspan">移动标题</span><input name="post[mobtitle]" type="text" id="mobtitle" maxlength="25" size="50" value="<?php echo $mobtitle;?>"/><?php tips('用于手机版的显示');?><span id="dmobtitle" class="f_red"></span>
    </td>
</tr>
<tr>
    <td class="tl"><span class="f_hid">*</span> 关键词(Tag)</td>
    <td><input name="post[tag]" type="text" size="60" value="<?php echo $tag;?>"/><?php tips('多个关键词请用空格隔开');?></td>
</tr>
<tr>
    <td class="tl"><span class="f_hid">*</span> 文档摘要</td>
    <td><textarea name="post[introduce]" style="width:90%;height:45px;"><?php echo $introduce;?></textarea></td>
</tr>
<!-- 自定义字段显示位置调整到作者下 -->
<tr id="link" style="display:<?php echo $islink ? '' : 'none';?>;">
<td class="tl"><span class="f_red">*</span> 链接地址</td>
<td><input name="post[linkurl]" type="text" id="linkurl" size="60" value="<?php echo $linkurl;?>"/> <span id="dlinkurl" class="f_red"></span></td>
</tr>
<tbody id="basic" style="display:<?php echo $islink ? 'none' : '';?>;">
<tr>
<td class="tl"><span class="f_red">*</span> 正文</td>
<td><textarea name="post[content]" id="content" class="dsn"><?php echo $content;?></textarea>
<?php echo deditor($moduleid, 'content', $MOD['editor'], '100%', 350);?><br/><span id="dcontent" class="f_red"></span>
</td>
</tr>
<?php
if($MOD['swfu'] && DT_EDITOR == 'fckeditor') { 
	include DT_ROOT.'/api/swfupload/editor.inc.php';
}
?>
<tr>
<td class="tl" height="30"><span class="f_hid">*</span> 内容选项</td>
<td>
<a href="javascript:pagebreak();Ds('subtitle');"><img src="admin/image/pagebreak.gif" align="absmiddle"/> 插入分页符</a>&nbsp;&nbsp;
<input type="checkbox" name="post[save_remotepic]" value="1"<?php if($MOD['save_remotepic']) echo 'checked';?>/> 下载远程图片&nbsp;&nbsp;
<input type="checkbox" name="post[clear_link]" value="1"<?php if($MOD['clear_link']) echo 'checked';?>/> 清除链接&nbsp;&nbsp;
截取内容 <input name="post[introduce_length]" type="text" size="2" value="<?php echo $MOD['introduce_length']?>"/> 字符至简介&nbsp;&nbsp;
设置内容第 <input name="post[thumb_no]" type="text" size="2" value=""/> 张图片为标题图
</td>
</tr>
<tbody id="subtitle" style="display:<?php echo $pagebreak ? '' : 'none';?>;">
<tr>
<td class="tl"><span class="f_hid">*</span> 分页标题</td>
<td>
<textarea name="post[subtitle]" style="width:90%;height:45px;"><?php echo $subtitle;?></textarea>
<br/>1行一个分页标题，按回车换行
</td>
</tr>
</tbody>
<tr>
    <td class="tl"><span class="f_hid">*</span> 副标题</td>
    <td><input name="post[subhead]" type="text" id="subhead" size="107" value="<?php echo $subhead;?>"/><span id="dsubhead" class="f_red"></span></td>
</tr>
<tr>
    <td class="tl"><span class="f_hid">*</span> 标题图片</td>
    <td><input name="post[thumb]" id="thumb" type="text" size="60" value="<?php echo $thumb;?>"/>&nbsp;&nbsp;<span onclick="Dthumb(<?php echo $moduleid;?>,Dd('level').value==2 ? 330 : <?php echo $MOD['thumb_width'];?>,Dd('level').value==2 ? 250 : <?php echo $MOD['thumb_height'];?>, Dd('thumb').value);" class="jt">[上传]</span>&nbsp;&nbsp;<span onclick="_preview(Dd('thumb').value);" class="jt">[预览]</span>&nbsp;&nbsp;<span onclick="Dd('thumb').value='';" class="jt">[删除]</span></td>
</tr>
<tr>
    <td class="tl"><span class="f_hid">*</span> 微信分享图</td>
    <td><input name="post[wxpic]" id="wxpic" type="text" size="80" value="<?php echo $wxpic;?>"/>&nbsp;&nbsp;<span onclick="Dthumb(<?php echo $moduleid;?>, 300,300,Dd('wxpic').value, '', 'wxpic');" class="jt">[上传]</span>&nbsp;&nbsp;<span onclick="_preview(Dd('wxpic').value);" class="jt">[预览]</span>&nbsp;&nbsp;<span onclick="Dd('wxpic').value='';" class="jt">[删除]</span></td>
</tr>
<style type="text/css">
    .hide{display: none;}
    #pic-display { list-style-type: none; margin: 0; padding: 0; width: 100%;}
    #pic-display li { margin: 3px 3px 3px 0; padding: 1px; float: left; width: 100px; height: 110px;overflow:hidden; font-size: 4em; text-align: center; }
    #pic-display li.hovered { width:100px;height:110px;}
    #pic-display li .pic {width:100px;height:90px;overflow:hidden;}
    #pic-display li.hovered .pic {border: solid 3px #1094fa;width:94px;height:84px;overflow:hidden;}
    #pic-display li .del_pic{float: left;padding: 4px 44px;width:12px; height: 12px; cursor: pointer;}
    #picinfo{color: #A8A297; font-size: 12px; padding: 5px 0px;clear: left}
    #picinfo span{margin-right: 15px;}
    .tspan{margin: 0px 10px 0px 20px;}
</style>
<tr>
    <td class="tl"><span class="f_hid">*</span> 多附件图</td>
    <td>
        <script id="singleupload"  type="text/plain"></script>
        <input readonly="readonly" type="text" id="form-input-readonly" name="post[picurl]" placeholder="" size="120" value="<?php echo $picurl;?>" >
        <button class="btn btn-sm btn-purple" id="btn-upload" type="button"><i class="ace-icon fa fa-upload"></i>上传</button>
        <ul id="pic-display">
            <?php
            foreach ($picurlArr as $k=>$pic){
                echo "<li picwidth='".$picwidthArr[$k]."' picheight='".$picheightArr[$k]."' pictitle='".$pictitleArr[$k]."' picdesc='".$picdescArr[$k]."' ><div class='ui-state-default' style='height: 90px;'><img src='$pic' class='pic' /></div><div style='height: 20px;'><img src='".DT_STATIC."member/image/img_delete.gif' class='del_pic' title='删除'></div></li>";
            }
            ?>
        </ul>
        <div id="picinfo" class="hide">
            <div>宽：<span id="picwidth"></span>高：<span id="picheight"></span> 标题：<span id="pictitle"></span> 描述：<span id="picdesc"></span></div>
        </div>
    </td>
    <input type="hidden" name="post[picwidth]" value="" />
    <input type="hidden" name="post[picheight]" value="" />
    <input type="hidden" name="post[pictitle]" value="" />
    <input type="hidden" name="post[picdesc]" value="" />
</tr>
<tr>
    <td class="tl"><span class="f_hid">*</span> 媒体库</td>
    <td><input name="post[mmlurl]" type="text" id="mmlurl" size="60" value="<?php echo $mmlurl;?>"/></td>
</tr>
<tr height="30">
<td class="tl"><span class="f_hid">*</span> 文档作者</td>
<td><input type="text" size="10" name="post[author]" value="<?php echo $action=='add'?$_truename:$author;?>" id="author"/> <img src="<?php echo $MODULE[2]['linkurl'];?>image/img_select.gif" width="12" height="12" title="选择常用作者" class="c_p" onclick="TopUse('author');"/>&nbsp;&nbsp;来源 <input type="text" size="12" name="post[copyfrom]" value="<?php echo $action=='add'?'':$copyfrom;?>" id="copyfrom"/>&nbsp;&nbsp;来源链接 <input type="text" size="25" name="post[fromurl]" value="<?php echo $fromurl;?>" id="fromurl"/> <img src="<?php echo $MODULE[2]['linkurl'];?>image/img_select.gif" width="12" height="12" title="选择常用来源" class="c_p" onclick="TopUse('from');"/></td>
</tr>

    <?php if($CP) { ?>
        <script type="text/javascript">
            var property_catid = <?php echo $catid;?>;
            var property_itemid = <?php echo $itemid;?>;
            var property_admin = 1;
        </script>
        <script type="text/javascript" src="<?php echo DT_PATH;?>file/script/property.js"></script>
        <tbody id="load_property" style="display:none;">
        <tr><td></td><td></td></tr>
        </tbody>
    <?php } ?>
    <?php echo $FD ? fields_html('<td class="tl">', '<td>', $item) : '';?>

<tr>
<td class="tl"><span class="f_hid">*</span> 插入投票</td>
<td><input name="post[voteid]" type="text" size="10" value="<?php echo $voteid;?>"/><?php tips('请填写投票ID，多个ID请用空格隔开');?></td>
</tr>
<tr>
<td class="tl"><span class="f_hid">*</span> 文档状态</td>
<td>
<?php
    $R = cache_read('right-'.$_userid.'.php');
    if($_groupid != 8 && !in_array('denypublish', $R[$moduleid]['index']['action'])){
?>
<input type="radio" name="post[status]" value="3" <?php if($status == 3) echo 'checked';?> id="status_3"/><label for="status_3">  发布</label>
<?php
    }
?>
<?php
    if($_admin == 1){
?>
<input type="radio" name="post[status]" value="2" <?php if($status == 2) echo 'checked';?> id="status_2"/><label for="status_2">  待审</label>
<input type="radio" name="post[status]" value="4" <?php if($status == 4) echo 'checked';?> id="status_4"/><label for="status_4">  待发</label>
<input type="radio" name="post[status]" value="1" <?php if($status == 1) echo 'checked';?> onclick="if(this.checked) Dd('note').style.display='';" id="status_1"/><label for="status_1">  拒绝</label>
<input type="radio" name="post[status]" value="0" <?php if($status == 0) echo 'checked';?> id="status_0"/><label for="status_0">  删除</label>
<?php
    }elseif($action=='add' || ($action=='edit'&&$status=='2')){
?>
<input type="radio" name="post[status]" value="2" <?php if($status == 2) echo 'checked';?> id="status_2"/><label for="status_2">  待审</label>
<?php
    }
?>
</td>
</tr>
<tr id="note" style="display:<?php echo $status==1 ? '' : 'none';?>">
<td class="tl"><span class="f_red">*</span> 拒绝理由</td>
<td><input name="post[note]" type="text"  size="40" value="<?php echo $note;?>"/></td>
</tr>
<tr>
<td class="tl"><span class="f_hid">*</span> 添加时间</td>
<td><?php echo dcalendar('post[addtime]', $addtime, '-', 1);?></td>
</tr>
<!--
<tr>
<td class="tl"><span class="f_hid">*</span> 所在地区</td>
<td><?php echo ajax_area_select('post[areaid]', '请选择', $areaid);?></td>
</tr>
-->
<tr>
<td class="tl"><span class="f_hid">*</span> 浏览次数</td>
<td><input name="post[hits]" type="text" size="10" value="<?php echo $hits;?>"/></td>
</tr>
<!--
<tr>
<td class="tl"><span class="f_hid">*</span> 内容收费</td>
<td><input name="post[fee]" type="text" size="5" value="<?php echo $fee;?>"/><?php tips('不填或填0表示继承模块设置价格，-1表示不收费<br/>大于0的数字表示具体收费价格');?>
</td>
</tr>
-->
<tr>
<td class="tl"><span class="f_hid">*</span> 内容模板</td>
<td><?php echo tpl_select('show', $module, 'post[template]', '默认模板', $template, 'id="template"');?><?php tips('如果没有特殊需要，一般不需要选择<br/>系统会自动继承分类或模块设置');?></td>
</tr>
<?php if($MOD['show_html']) { ?>
<tr>
<td class="tl"><span class="f_hid">*</span> 自定义文件路径</td>
<td><input type="text" size="50" name="post[filepath]" value="<?php echo $filepath;?>" id="filepath"/>&nbsp;<input type="button" value="重名检测" onclick="ckpath(<?php echo $moduleid;?>, <?php echo $itemid;?>);" class="btn"/>&nbsp;<?php tips('可以包含目录和文件 例如 destoon/b2b.html<br/>请确保目录和文件名合法且可写入，否则可能生成失败');?>&nbsp; <span id="dfilepath" class="f_red"></span></td>
</tr>
<?php } ?>
</table>
<div class="sbt"><input type="submit" id="submit" name="submit" value="<?php echo $action == 'edit' ? '修 改' : '添 加';?>" class="btn-g"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="<?php echo $action == 'edit' ? '返 回' : '取 消';?>" class="btn" onclick="Go('?moduleid=<?php echo $moduleid;?>&file=<?php echo $file;?>');"/></div>
</form>
<?php load('clear.js'); ?>
<?php if($action == 'add') { ?>
<form method="post" action="?">
<input type="hidden" name="moduleid" value="<?php echo $moduleid;?>"/>
<input type="hidden" name="file" value="<?php echo $file;?>"/>
<input type="hidden" name="action" value="<?php echo $action;?>"/>
<input type="hidden" name="catid" value="<?php echo $catid;?>"/>
<div class="tt">单页采编</div>
<table cellspacing="0" class="tb">
<tr>
<td class="tl"><span class="f_hid">*</span> 目标网址</td>
<td><input name="url" type="text" size="80" value="<?php echo $url;?>"/>&nbsp;&nbsp;<input type="submit" value=" 获 取 " class="btn"/>&nbsp;&nbsp;<input type="button" value=" 管理规则 " class="btn" onclick="Dwidget('?file=fetch', '管理规则');"/></td>
</tr>
</table>
</form>
<?php } ?>
<!--pic info dialog S-->
<style type="text/css">
    #dialog-confirm td {padding: 5px;}
</style>
<div id="dialog-confirm" title="修改当前图片信息" hidden="hidden">
    <table style="border:0px solid red;width:100%">
        <tr>
            <td style="width: 10%;" align="right">宽度</td>
            <td style="width: 30%;"><input type="text" id="p_width" style="width: 60px;">px</td>
            <td style="width: 10%;" align="right">高度</td>
            <td style="width: 50%"><input type="text" id="p_height" style="width: 60px;">px</td>
        </tr>
        <tr>
            <td style="width: 10%;" align="right">标题</td>
            <td colspan="3" style="width: 90%;"><input type="text" id="p_title" placeholder="图片的概要信息" style="width: 100%;" ></td>
        </tr>
        <tr>
            <td style="width: 10%;" align="right">描述</td>
            <td colspan="3"  style="width: 90%;"><textarea id="p_desc" placeholder="图片的描述信息"style="width: 100%; height: 50px;"></textarea></td>
        </tr>
    </table>
</div>
<!--pic info dialog E-->
<script type="text/javascript">
    var checkSubmitFlg=false;
    function check_title() {
	if(Dd('title').value.length < 2) {
		alert('请填写标题');
	} else {
		Dd('kw').value = Dd('title').value;
		Dd('check_title').submit();
	}
}
function TopUse(a) {
	mkDialog('', '<iframe src="?moduleid=<?php echo $moduleid;?>&action='+a+'" width="650" height=250" border="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" framespacing="0" frameborder="0" scrolling="yes"></iframe>', '请选择', 675, 0, 0);
}
function check() {
    if(checkSubmitFlg==true){return false;}
	var l;
	var f;
	f = 'catid_1';
	if(Dd(f).value == 0) {
		Dmsg('请选择所属分类', 'catid', 1);
		return false;
	}
	f = 'title';
	l = Dd(f).value.length;
	if(l < 2) {
		Dmsg('标题最少2字，当前已输入'+l+'字', f);
		return false;
	}
	if(Dd('islink').checked) {
		f = 'linkurl';
		l = Dd(f).value.length;
		if(l < 12) {
			Dmsg('请输入正确的链接地址', f);
			return false;
		}
	} else {
		f = 'content';
		l = FCKLen();
		if(l < 5) {
			Dmsg('内容最少5字，当前已输入'+l+'字', f);
			return false;
		}
	}
	<?php echo $FD ? fields_js() : '';?>
	<?php echo $CP ? property_js() : '';?>

    //***@#$**** 20180426 多图上传 2 S
    var widthAarray		= new Array();
    var heightAarray	= new Array();
    var titleAarray	= new Array();
    var descAarray	= new Array();
    $("#pic-display li").each(function(){
        widthAarray.push($(this).attr('picwidth'));
        heightAarray.push($(this).attr('picheight'));
        titleAarray.push($(this).attr('pictitle'));
        descAarray.push($(this).attr('picdesc'));
    });
    $("input[name='post[picwidth]']").val(widthAarray.join('|'));
    $("input[name='post[picheight]']").val(heightAarray.join('|'));
    $("input[name='post[pictitle]']").val(titleAarray.join('|'));
    $("input[name='post[picdesc]']").val(descAarray.join('|'));
    //***@#$****20180426 多图上传 2 E

    checkSubmitFlg=true;
	return true;
}
//***@#$*** 20180426 多图上传 1 S

//***@#$ 2018-08-21 16:09 by lmx | 标题字数提示
function title_count(id,did){
    $('#'+id).keyup(function () {
        var title_length=$("#"+id).val().length;
        // var length=50;
        // var in_length=length-title_length;
        $('#'+did).html('您已输入'+title_length+'字');
    });
}
title_count('title','dtitle');
title_count('headline','dheadline');
title_count('mobtitle','dmobtitle');
title_count('subhead','dsubhead');
//***@#$ 2018-08-21 16:09 by lmx | 标题字数提示

$(function(){
    ue.ready(function(){
        var isDdefaultWwater = <?php echo $MOD['default_water']?:0; ?>;
        if(1 == isDdefaultWwater){
            ue.execCommand("watermaker", "watermaker");
        }else{
            ue.execCommand("watermaker", "nil");
        }
    });
    var _ue = UE.getEditor('singleupload',{
        serverUrl :UPPath+"?from=editor&moduleid=<?php echo $moduleid;?>"
    })
    _ue.ready(function(){
        _ue.hide()
        _ue.addListener('beforeinsertimage', function(t, arg){
            if($("input[name='post[picurl]']").val()!=''){
                var pics = $("input[name='post[picurl]']").val().split("|");
            }else{
                var pics = [];
            }
            for(var no in arg){
                pics.push(arg[no].src)
                $("#pic-display").append("<li><div class='ui-state-default' style='height: 90px;'><img src='"+arg[no].src+"' class='pic' /></div><div style='height: 20px;'><img src='<?php echo DT_STATIC;?>member/image/img_delete.gif' class='del_pic' title='删除'></div></li>")
            }
            $("input[name='post[picurl]']").val(pics.join('|'))
        })
    })

    $("#btn-upload").click(function(){
        var myimg = _ue.getDialog("insertimage")
        myimg.open()
    })

    $( "#pic-display" ).sortable({opacity: 0.5,stop:function(event, ui){
        var newsorts = new Array();
        $("#pic-display li img.pic").each(function(){
            newsorts.push($(this).attr('src'));
        })
        $("input[name='post[picurl]']").val(newsorts.join('|'));
    }});
    $( "#pic-display").disableSelection();

    //***@#$ 2018-08-15 17:08 by lmx | 附件图删除
    $(".del_pic").bind('click',function () {
        if(confirm(L['confirm_del'])){
            var idx=$(this).parent().parent('li').index();
            var urlArr=$("input[name='post[picurl]']").val().split('|');
            urlArr.splice(idx,1);
            $("input[name='post[picurl]']").val(urlArr.join('|'));
            $(this).parent().parent('li').remove();
        }
        event.stopPropagation();//阻止事件冒泡
    })
    //***@#$ 2018-08-15 17:09 by lmx | 附件图删除

    $("#pic-display").on('click', "li", function(){
        $("#pic-display li").each(function(){$(this).removeClass('hovered')});
        $(this).addClass('hovered');
        $("#picwidth").text($(this).attr('picwidth')?$(this).attr('picwidth')+"px":"");
        $("#picheight").text($(this).attr('picheight')?$(this).attr('picheight')+"px":"");
        $("#pictitle").text($(this).attr('pictitle')?$(this).attr('pictitle'):"");
        $("#picdesc").text($(this).attr('picdesc')?$(this).attr('picdesc'):"");
        $("#picinfo").removeClass('hide');
    });

    $("#pic-display").on('dblclick', "li", function(){
        var picwidth	= $(this).attr('picwidth');
        var picheight	= $(this).attr('picheight');
        var pictitle	= $(this).attr('pictitle');
        var picdesc	= $(this).attr('picdesc');
        var curele		= $(this);
        $("#p_width").val(picwidth);
        $("#p_height").val(picheight);
        $("#p_title").val(pictitle);
        $("#p_desc").val(picdesc);
        $( "#dialog-confirm").dialog({
            buttons:{
                "保存":function(){
                    curele.attr('picwidth', $.trim($("#p_width").val()));
                    curele.attr('picheight', $.trim($("#p_height").val()));
                    curele.attr('pictitle', $.trim($("#p_title").val()));
                    curele.attr('picdesc', $.trim($("#p_desc").val()));
                    curele.click();
                    $(this).dialog( "close" );
                },
                "取消":function(){
                    $(this).dialog('close');
                }
            },
            title:'修改当前图片信息',
            resizable: false,
            width: 600,
            modal: true,
            draggable: false
        });
    });
});
//***@#$*** 20180426 多图上传 1 E
</script>
<script type="text/javascript">Menuon(<?php echo $menuid;?>);</script>
<?php include tpl('footer');?>